"use strict";
cc._RF.push(module, 'ffe99TOc+ZGoIkZiOjLra0D', 'TopUI');
// scripts/TopUI.ts

Object.defineProperty(exports, "__esModule", { value: true });
var Model_1 = require("./Model");
var Config_1 = require("./Config");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var TopUI = /** @class */ (function (_super) {
    __extends(TopUI, _super);
    function TopUI() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.label_level = null;
        _this.text = 'hello';
        return _this;
    }
    TopUI.prototype.onLoad = function () {
        if (Model_1.default.game.selectedModel == 1)
            this.label_level.getComponent(cc.Label).string = Model_1.default.game.selectedLevel + '/' + (Config_1.default.preciseLevels.length - 1);
        else if (Model_1.default.game.selectedModel == 2)
            this.label_level.getComponent(cc.Label).string = Model_1.default.game.selectedLevel + '/' + (Config_1.default.brickLevels.length - 1);
        else if (Model_1.default.game.selectedModel == 3)
            this.label_level.getComponent(cc.Label).string = Model_1.default.game.selectedLevel + '/' + (Config_1.default.dragLevels.length - 1);
        else if (Model_1.default.game.selectedModel == 4)
            this.label_level.getComponent(cc.Label).string = '第' + Model_1.default.game.selectedLevel + '关';
        if (Model_1.default.game.selectedModel != 4) {
            this.node.getChildByName('img_money').active = false;
            this.node.getChildByName('star_txt').active = false;
            // this.node.getChildByName('level_txt').active=false;
            this.node.getChildByName('btn_retry').active = true;
        }
        //动态调整top位置
        var size = cc.view.getVisibleSize();
        if (size.height / size.width > 2) {
            this.node.getComponent(cc.Widget).top = 115;
        }
        else {
            this.node.getComponent(cc.Widget).top = 60;
        }
    };
    TopUI.prototype.start = function () {
        var star = 0;
        for (var i = 0; i < Model_1.default.game.drawLevelInfo.length; i++) {
            if (Model_1.default.game.drawLevelInfo[i] > 0)
                star += Model_1.default.game.drawLevelInfo[i];
        }
        this.node.getChildByName('star_txt').getComponent(cc.Label).string = star + '/' + (Config_1.default.drawLevels.length - 1) * 3;
    };
    TopUI.prototype.onBackClick = function () {
        cc.director.loadScene('menu');
    };
    TopUI.prototype.onReplayClick = function () {
        if (Model_1.default.game.selectedModel == 1)
            cc.director.loadScene('game');
        else if (Model_1.default.game.selectedModel == 2)
            cc.director.loadScene('gameDrop');
        else if (Model_1.default.game.selectedModel == 3)
            cc.director.loadScene('gameDrag');
        else if (Model_1.default.game.selectedModel == 4)
            cc.director.loadScene('gameDraw');
    };
    TopUI.prototype.onRankClick = function () {
    };
    __decorate([
        property(cc.Label)
    ], TopUI.prototype, "label_level", void 0);
    __decorate([
        property
    ], TopUI.prototype, "text", void 0);
    TopUI = __decorate([
        ccclass
    ], TopUI);
    return TopUI;
}(cc.Component));
exports.default = TopUI;

cc._RF.pop();